﻿using Abp.Dependency;
using Abp.Events.Bus.Handlers;
using RMM.Core.Entity.Massagistes;
using RMM.Core.Entity.Orders;
using RMM.Core.Massagistes;
using RMM.Core.Orders;
using RMM.Core.UserService;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RMM.Orders.Events
{
    public class OrderItemEventHandler : IEventHandler<OrderItemEventData>, ITransientDependency
    {
        private readonly IOrderItemService _orderItemsService;
        private readonly IUserService _userService;
        private readonly IMassagistService _massagistService;
        private readonly IMassagistExtendService _massagistExtendService;

        public OrderItemEventHandler(IOrderItemService orderItemsService
            , IUserService userService
            , IMassagistService massagistService
            , IMassagistExtendService massagistExtendService)
        {
            _orderItemsService = orderItemsService;
            _userService = userService;
            _massagistService = massagistService;
            _massagistExtendService = massagistExtendService;
        }

        public async void HandleEvent(OrderItemEventData eventData)
        {
            var orderItem = new OrderItems()
            {
                CreatorUserId = eventData.order.UserId,
                CreationTime = DateTime.Now,
                OrderId = eventData.order.Id,
                Price = eventData.order.Price,
                ProjectId = eventData.ProjectId
            };

            await _orderItemsService.CreateAsync(orderItem);
        }
    }
}
